//base
import Taro, { Component } from '@tarojs/taro'
import { View, Text } from '@tarojs/components'
//less
import './index.less'

class If extends Component {
  componentWillMount() {
    //onLoad
  }

  componentDidMount() {
    //onready
  }

  componentDidShow() {
    //onshow
  }

  componentDidHide() {
    //onhide
  }

  componentWillUnmount() {
    //onUnload
  }

  delay(time = 0) {
    return new Promise(resolve => {
      setTimeout(() => {
        resolve()
      }, time)
    })
  }

  render() {
    const { visible } = this.props
    return process.env.TARO_ENV === 'h5' ? (
      visible ? (
        this.props.children
      ) : (
        this.props.renderElse
      )
    ) : (
      <Block>{visible ? this.props.children : this.props.renderElse}</Block>
    )
  }
}

export default If
